/*
 * 对文件进行切片上传 
 */
var file;
var fileInput = document.querySelector('#fileInput');
var progressText = document.querySelector('#progress-text');

fileInput.addEventListener("change", function() {
	file = this.files[0];
	progressText.innerText = "等待上传";
});



function uploadFile(){
	//jQuery+ajax实现文件上传。参考： https://blog.csdn.net/qq_43097393/article/details/82218585
	var formData = new FormData();
	formData.append("video", $("#fileInput")[0].files[0]);
	formData.append("regionCode", $("#regionCode").val());

	progressText.innerText = "上传中...";
	$.ajax({
		url: "/video/upload",
		type: "POST",
		data: formData,
		dataType: "json",
		contentType: false,
		processData: false,
		success: function(response) {
			var res = JSON.parse(response);
			if(res.code == "0") {
				alert("上传成功!");
				progressText.innerText = "上传成功";
			} else {
				alert(res.message);
				progressText.innerText = "上传出错";
			}
		},
		error: function(status) {
			
		}
	});
	
}
